import { app as t, BrowserWindow as r } from "electron";
import { fileURLToPath as d } from "node:url";
import e from "node:path";
const a = e.dirname(d(import.meta.url));
process.env.APP_ROOT = e.join(a, "..");
const s = process.env.VITE_DEV_SERVER_URL, R = e.join(process.env.APP_ROOT, "dist-electron"), l = e.join(process.env.APP_ROOT, "dist");
process.env.VITE_PUBLIC = s ? e.join(process.env.APP_ROOT, "public") : l;
let o;
function c() {
  if (o = new r({
    width: 1200,
    height: 900,
    icon: e.join(process.env.VITE_PUBLIC, "electron-vite.svg"),
    webPreferences: {
      preload: e.join(a, "preload.mjs"),
      nodeIntegration: !1,
      contextIsolation: !0,
      webSecurity: !1
    }
  }), o.webContents.on("did-finish-load", () => {
    o == null || o.webContents.send("main-process-message", (/* @__PURE__ */ new Date()).toLocaleString());
  }), console.log("VITE_DEV_SERVER_URL", s), s) {
    const n = e.join(l, "index.html");
    console.log("Loading index.html from:", n), o.loadURL(n).catch((i) => {
      console.error("Failed to load index.html:", i);
    });
  } else {
    const n = e.join(l, "index.html");
    console.log("Loading index.html from:", n), o.loadFile(n).catch((i) => {
      console.error("Failed to load index.html:", i);
    });
  }
}
t.on("window-all-closed", () => {
  process.platform !== "darwin" && (t.quit(), o = null);
});
t.on("activate", () => {
  r.getAllWindows().length === 0 && c();
});
t.whenReady().then(c);
export {
  R as MAIN_DIST,
  l as RENDERER_DIST,
  s as VITE_DEV_SERVER_URL
};
